<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <input type="button" value="跳转" class="btn">
    <span id='num'>5</span>
    <script src="../jquery1.11.3.js"></script>
    <script>
    
        let btn = document.getElementsByClassName('btn')[0]
        // btn.onclick = function () {
        //     console.dir(location)
        //     // location.href = 'http://www.baidu.com'
        //     location.assign('http://www.qq.com') //跳转到指定的url网址，也能后退
        //     // location.replace('http://www.example.com') //不能后退
        // }
        // 5秒自动跳转到百度首页
        let $num=$('#num')
        let timer=setInterval(function () {
            $num.text((index,value)=>{
                if(value==1){
                    location.assign('http://www.qq.com')
                    clearInterval(timer)
                }
                return parseInt(value)-1
            })
          
        }, 1000)
    </script>
</body>

</html>